package org.cangku.controller;

import org.cangku.dao.FenLeiDao;
import org.cangku.entity.Fenlei;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/fenlei")
public class FenLeiController {
    @Autowired
    private FenLeiDao fenLeiDao;
    /*查询分类*/
    @RequestMapping("/queryfenlei")
    @ResponseBody
    public List<Fenlei> queryFenlei(){
        return fenLeiDao.getFenLei();
    }


    @RequestMapping("/insert")
    @ResponseBody
    public List<Fenlei> insert(String name){
        fenLeiDao.insert(name);
        return fenLeiDao.getFenLei();
    }
    @RequestMapping("/delete")
    @ResponseBody
    public List<Fenlei> delete(int id){
        fenLeiDao.delete(id);
        return fenLeiDao.getFenLei();
    }

    @RequestMapping("/update")
    @ResponseBody
    public List<Fenlei> update(String name,int id){
        fenLeiDao.update(name,id);
        return fenLeiDao.getFenLei();
    }
}
